'use strict';

const Controller = require('egg').Controller;

class GirlManage extends Controller {
  async addGirl() {
    const { ctx } = this;
    const params = {
      id: 4,
      name: 'ss',
      age: 23,
      skill: 'sssspretty'
    };
    const res = await ctx.service.testdb.addGirl(params);
    console.log(11111111111, res);
    if (res !== null) {
      ctx.body = '添加女孩-成功！';
    } else {
      ctx.body = '添加失败！';
    }
  }

  async delGirl() {
    const { ctx } = this;
    const id = { 'id': 4 };
    const res = await ctx.service.testdb.delGirl(id);
    console.log(res);
    if (res) {
      ctx.body = '删除女孩-成功';
    } else {
      ctx.body = '删除失败';
    }

  }

  async updateGirl() {
    const { ctx } = this;
    const params = {
      id: 3,
      name: '可心',
      age: 20,
      skill: 'beautiful'
    };
    const res = await ctx.service.testdb.updateGirl(params);
    if (res) {
      ctx.body = '修改女孩-成功';
    } else {
      ctx.body = '修改失败';
    }
  }

  async getGirls() {
    const { ctx } = this;
    const res = await ctx.service.testdb.getGirl();
    ctx.body = JSON.stringify(res);
  }
}

module.exports = GirlManage;